package cn.java79.springcore.printerano;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author oldliu
 * @since 1.0
 */
//打印机
@Service
public class Printer {
    //牌子
    @Value("惠普炫彩900")
    private String brand;
    //价格
    @Value("1500")
    private int money;
    //默认byName,可以指定名字
    @Resource(name = "whiteInk")
    private Ink ink;

    @Autowired//自动绑定，默认按照类型：ByType
    @Qualifier("A4")//指定名字！
    private TextPaper paper;

//    public void set(@Qualifier("a4")Ink i){
//
//    }

    public void print(String str){
        System.out.println("这个打印机"+brand+"价格是"+money+"元，启动了。。。");
        System.out.println("使用"+ink.getColor()+"的墨水来打印：");
        paper.print(str);
    }

//    public void setBrand(String brand) {
//        this.brand = brand;
//    }
//
//    public void setMoney(int money) {
//        this.money = money;
//    }
//
//    public void setInk(Ink ink) {
//        this.ink = ink;
//    }
//
//    public void setPaper(TextPaper paper) {
//        this.paper = paper;
//    }

    @Override
    public String toString() {
        return "Printer{" +
                "brand='" + brand + '\'' +
                ", money=" + money +
                ", ink=" + ink +
                ", paper=" + paper +
                '}';
    }
}
